package es.ikex.pojo;

public class ValidarDni {
	public static boolean chequeaDNI(String dni) {
		final String letra = "TRWAGMYFPDXBNJZSQVHLCKE";
		Boolean res = false;
		if (dni.length() == 9) {
			res = true;
			for (int i = 0; i < dni.length() - 1; i++) {
				res = res && Character.isDigit(dni.charAt(i));
			}
			Integer valor = new Integer(dni.substring(0, 8));
			int aux = valor % 23;
			Character letraReal = dni.charAt(8);
			Character letraCalculada = letra.charAt(aux);
			if (letraReal == letraCalculada) {
				res = true;
			}

		}
		return res;
	}
}
